{% extends "transsys/base_transsys.html" %}
{%block center%}
<div class="edit_form">
    <h2>Identify Attractors</h2>
    <fieldset><legend></legend>
        <form id="identify_attractors" action="identifyAttractors" method="post" class="edit">
            {% csrf_token %}
            <fieldset><legend></legend>
                <div class="input-field">
                    <label>Number of time steps:</label>
                    <span class="helptext">Enter number of time steps</span>
                    <input type="text" name="timestep" value="{{input.timestep}}"/>
                </div>
                <div class="input-field">
                    <label>Number of simulations:</label>
                    <span class="helptext">Enter number of simulations</span>
                    <input type="text" name="no_simulations" value="{{input.no_simulations}}"/>
                </div>
                <div class="input-field">
                    <label>Initial expression level</label>
                    <span class="helptext">Set the minimum and maximum of the randomly generated initial factor concentrations.</span>
                    <div>
                        <a id="more" rev="transsys program" class="more" href="#" title="Click here for specify minimum and maximum initial state for each factor." ></a>
                        <a id="less" rev="transsys program" class="less" href="#" title="Click here for specify minimum and maximum initial state for all factors." ></a>
                    </div>
                    <div id="data_set">
                        <div id="all" class="input_field">
                            <label>All factors:</label>
                            <label>Min:</label>
                            <input id="all_min" type="text" name="c_min" value="{{input.c_min}}"/>
                            <label>Max:</label>
                            <input id="all_max" type="text" name="c_max" value="{{input.c_max}}"/>
                        </div>
                        <div id="details">
                            {% if input %}
                            {%for k,v in input.min_max_dict.items %}
                            <div class="input_field">
                                <label>{{k}} :</label>
                                <label>Min:</label><input class="min" type="text" name="{{k}}_min" value="{{v.0}}"/>
                                <label>Max:</label><input class="max" type="text" name="{{k}}_max" value="{{v.1}}"/>
                            </div>
                            {% endfor %}
                            {% else %}
                            {%for f in request.session.ts_program.tp.factor_list %}
                            <div class="input_field">
                                <label>{{f.name}} :</label>
                                <label>Min:</label><input class="min" type="text" name="{{f.name}}_min"/>
                                <label>Max:</label><input class="max" type="text" name="{{f.name}}_max"/>
                            </div>
                            {% endfor %}
                            {% endif %}
                        </div>
                    </div>

                </div>
            </fieldset>

            <button type="submit" name="submit">Submit</button>
        </form>
    </fieldset>

    {% if fc_list %}
    <div class="hidden">
        <h2>Factor concentration table:</h2>
        <table id="fc_table">
            <colgroup>
                <col class="oce-first" />
            </colgroup>
            <tr>
                <th scope="col">Round</th>
                {% for f in request.session.ts_program.tp.factor_list %}
                <th scope="col" >{{f.name}}</th>
                {% endfor %}
            </tr>
            {% for fc in fc_list %}
            <tr>
                <td>{{forloop.counter}}</td>
                {% for c in fc %}
                <td>{{c}}</td>
                {% endfor %}
            </tr>
            {% endfor %}
        </table>
    </div>
    <div style="display: block;">
        <table class="center1">
            {% if factor_list %}
            {% else %}
            {% for f1 in request.session.ts_program.tp.factor_list %}
            <tr>
                {% for f2 in request.session.ts_program.tp.factor_list %}
                {% if f1.name == f2.name %}
                <td style="text-align:center;"><strong>{{f1.name}}</strong></td>
                {% else %}
                <td>
                    <a class="thumbnail" title="Plot expression data of factors {{f1.name}} and {{f2.name}}" href="{% url tsworkbench.views.ts.plotAttractors request.session.ts_program.tp.name f1.name f2.name 'full' %}">
                        <img src="{% url tsworkbench.views.ts.plotAttractors request.session.ts_program.tp.name f1.name f2.name 'thumbnail' %}" alt="Plot expression data of factors {{f1.name}} and {{f2.name}}"/>
                    </a>
                </td>
                {% endif %}
                {% endfor %}
            </tr>
            {% endfor %}
            {% endif %}
        </table>
        <a class="link-button" href="{% url tsworkbench.views.ts.downloadAttractors request.session.ts_program.tp.name %}" title="Download data as text format"> Download result </a>
    </div>
    {% endif %}

</div>
{% endblock %}